<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/two.js" type="module"></script>
</head>

<body>

    <script>

        //async await
        function Ajax(url){
            let p = new Promise(function(resolve,reject){
                let xhr = new XMLHttpRequest()
                xhr.open('GET',url,true)
                xhr.send()
                xhr.onreadystatechange=function(){
                    if(xhr.readyState == 4 && xhr.status == 200){
                        resolve(xhr.responseText)
                    }
                }
            })
            return p
        }

        async function fn(){
            let res = await Ajax('./data/1.json')
            // console.log(res);
        }

        fn()

        //类 继承 class

        function clFun(name){
            this.name = name
        }
        clFun.prototype.say = function(){
            console.log('chuang');
        }
        let clObj = new clFun('he')

        // console.log(clObj);
        // clObj.say()

        function clFun2(num){
            clFun.call(this,num)
        }
        clFun2.prototype = clFun.prototype

        let clObj2 = new clFun2('wang')
        
        // console.log(clObj2);


        // class
        class Daytime{
            constructor(n){
                this.n = n
            }
            change(n){
                console.log(n);
            }
        }
        // let le = new Daytime('baitian')
        // le.change('baitian')
        // console.log(le);

        class Night extends Daytime{
            constructor(n){
                super(n)
            }
        }

        // let ler = new Night('wanshang')
        // ler.change('wanshng')
        // console.log(ler);

    </script>
</body>

</html>